import type { JobLogForm, JobLogQuery, JobLogVO } from './model';

import type { ID, IDS, PageResult } from '#/api/common';

import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';

enum Api {
  jobLogClean = '/monitor/jobLog/clean',
}
/**
 * 查询定时任务调度日志列表
 * @param params
 * @returns 定时任务调度日志列表
 */
export function jobLogList(params?: JobLogQuery) {
  return requestClient.get<PageResult<JobLogVO>>('/monitor/jobLog/list', {
    params,
  });
}

/**
 * 导出定时任务调度日志列表
 * @param params
 * @returns 定时任务调度日志列表
 */
export function jobLogExport(params?: JobLogQuery) {
  return commonExport('/monitor/jobLog/export', params ?? {});
}

/**
 * 查询定时任务调度日志详情
 * @param jobLogId id
 * @returns 定时任务调度日志详情
 */
export function jobLogInfo(jobLogId: ID) {
  return requestClient.get<JobLogVO>(`/monitor/jobLog/${jobLogId}`);
}

/**
 * 新增定时任务调度日志
 * @param data
 * @returns void
 */
export function jobLogAdd(data: JobLogForm) {
  return requestClient.postWithMsg<void>('/monitor/jobLog', data);
}

/**
 * 更新定时任务调度日志
 * @param data
 * @returns void
 */
export function jobLogUpdate(data: JobLogForm) {
  return requestClient.putWithMsg<void>('/monitor/jobLog', data);
}

/**
 * 删除定时任务调度日志
 * @param jobLogId id
 * @returns void
 */
export function jobLogRemove(jobLogId: ID | IDS) {
  return requestClient.deleteWithMsg<void>(`/monitor/jobLog/${jobLogId}`);
}

/**
 * 清空全部分页日志
 */
export function jobLogClean() {
  return requestClient.deleteWithMsg<void>(Api.jobLogClean);
}
